import Taro, { Component } from '@tarojs/taro'
import { View, Text, Swiper, SwiperItem } from '@tarojs/components'
import './index.less'
import { AtButton,AtAvatar  } from 'taro-ui'
var QQMapWX = require('../../comment/liba/qqmap-wx-jssdk.js')
var qqmapsdk;
qqmapsdk = new QQMapWX({
  key: 'WVRBZ-XLB6D-QGF46-P7UDQ-E6LA6-NPBOJ'
});

export default class Index extends Component {
  constructor(props) {
    super(props)
    this.state = {
      isToggleOn: true,
      markers: null
    }
  }

  onClick = (e) => {
    console.log(e)
    e.stopPropagation()
    this.setState(prevState => ({
      isToggleOn: !prevState.isToggleOn
    }))
  }

  nearby_search = () => {
    var _this = this;
    // 调用接口
    // qqmapsdk.search({
    //   keyword: 'kfc',  //搜索关键词
    //   location: '39.980014,116.313972',  //设置周边搜索中心点
    //   success: function (res) { //搜索成功后的回调
    //     var mks = []
    //     for (var i = 0; i < res.data.length; i++) {
    //       mks.push({ // 获取返回结果，放到mks数组中
    //         title: res.data[i].title,
    //         id: res.data[i].id,
    //         latitude: res.data[i].location.lat,
    //         longitude: res.data[i].location.lng,
    //         iconPath: "../../stails/img/me.png", //图标路径
    //         width: 20,
    //         height: 20
    //       })
    //     }
    //     console.log(_this)
    //     _this.setData({ //设置markers属性，将搜索结果显示在地图中
    //       markers: mks
    //     })
    //   },
    //   fail: function (res) {
    //     console.log(res);
    //   },
    //   complete: function (res) {
    //     console.log(res);
    //   }
    // });
  }

  config = {
    navigationBarTitleText: '首页',

  }

  componentWillMount() {
    console.log(this)
  }

  componentDidMount() {
    // Taro.navigateTo({
    //   url: '../details/details?id=31'
    // })

  }



  render() {
    return (
      <View className='map_container' onClick={this.nearby_search}>

        <View className='map_query'></View>
       
        <map id="myMap"

          style="width:100%;height:200px;"
          longitude="116.313972"
          latitude="39.980014" scale='16'>
        </map>
        <AtButton type='primary' size='normal'>按钮文案</AtButton>
<AtButton type='primary' size='small'>按钮文案</AtButton>
      </View>
    )
  }
}

